<%
var headerPart = {
%>
<% include("/include/treeview.html"){} %>
<style type="text/css">
	.ztree {overflow:auto;margin:0;_margin-top:5px;padding:5px 0 0 0px;}
	.ztree *{font-size: 14px!important;}
</style>
<% }; %>
<% layout("/layouts/micro.html",{headerSection:headerPart,background:"true"}){ %>
	<div class="childrenBody" id="content">
		<div class="layui-row layui-col-space15">
		    <div class="layui-col-md2">
		      <div class="layui-card">
			  	<div class="layui-card-header">机构列表</div>
		        <div id="left" class="layui-card-body" style="padding: 0px;">
			         <div id="ztree" class="ztree" ></div>
		        </div>
		      </div>
		    </div>
		    <div class="layui-col-md10">
		      <div class="layui-card">
		        <div id="right" class="layui-card-body" style="padding: 0px;">
			        <iframe id="userContent" src="${ctx}/sys/user/list" width="100%" height="100%" frameborder="0"></iframe>
		        </div>
		      </div>
		    </div>
	    </div>
	</div>
	<script type="text/javascript">
		var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'0'}},
			callback:{onClick:function(event, treeId, treeNode){
					var id = treeNode.id == '0' ? '' :treeNode.id;
					$('#userContent').attr("src","${ctx}/sys/user/list?office.id="+id+"&office.name="+treeNode.name);
				}
			}
		};
		
		function refreshTree(){
			$.getJSON("${ctx}/sys/office/treeData",function(data){
				$.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
			});
		}
		refreshTree();
		
		/*var leftWidth = $("#left").width(); // 左侧窗口大小
		var htmlObj = $("html"), mainObj = $("#main");
		var frameObj = $("#left, #right, #right iframe");
		function wSize(){
			var strs = getWindowSize().toString().split(",");
			htmlObj.css({"overflow-x":"hidden", "overflow-y":"hidden"});
			frameObj.height(strs[0] - 60);
			var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
			$("#right").width($("#content").width()- leftWidth - 10).height(frameObj.height());
			$("#ztree").width(leftWidth - 10).height(frameObj.height());
		}*/

        var leftWidth = $("#left").width();// 左侧窗口大小
        function wSize(){
            var strs=getWindowSize().toString().split(",");
            $("#ztree").height(strs[0]-70);
            $("#userContent").height(strs[0]-30);
            $("#ztree").width(leftWidth - 10);
        }
	</script>
	<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>
<%}%>